package com.sen.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sen.dao.DruginfoDao;
import com.sen.dao.WarehouseDao;
import com.sen.entity.DruginfoEntity;
import com.sen.entity.WarehouseEntity;
import com.sen.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("warehouseService")
public class WarehouseServiceImpl extends ServiceImpl<WarehouseDao, WarehouseEntity> implements WarehouseService {

    @Autowired
    WarehouseDao warehouseDao;
    @Autowired
    DruginfoDao druginfoDao;

    @Override
    public void updCount(Integer count, Integer lno) {
        warehouseDao.updCount(count, lno);
    }

    @Override
    public IPage<DruginfoEntity> querList(Page<DruginfoEntity> page, Map<String, String> advent) {
        if (advent.get("tid")!=null){
            String tid = advent.get("tid");
            List<Integer> types = druginfoDao.queryType(tid);
            return warehouseDao.queryList(page,advent,types);
        }
        else{
            return warehouseDao.queryList(page,advent,null);
        }
    }

    @Override
    public List<WarehouseEntity> queryLnoByMid(Integer mid) {
        return warehouseDao.queryLnoByMid(mid);
    }
}
